package com.fairytask.engine.components.text
{
	import com.fairytask.engine.components.BaseComponent;
	import com.fairytask.engine.define.Filter;
	import com.fairytask.resource.StaticIni;
	
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;

	/**
	 * 静态文字 只改变颜色 滤镜 
	 * @author hanjy
	 * 
	 */	
	public class StaticText extends BaseComponent
	{
		private var _txt	:TextField	=	null;
		private var _tf	:TextFormat	=	null;
		private var _color	:String		=	"FFCB4A";
		private var _labelFilter	:GlowFilter;
		/*文字*/
		private var _htmlStr	:String	=	"";
		
		public function StaticText(txtColor:String="FFCB4A",size:int=12)
		{
			super();
			
			_color	=	txtColor;
			_labelFilter	=	Filter.COMMON_LABEL_FILTER;
			
			_txt	=	new TextField();
			_txt.multiline			=	true;
			_txt.autoSize			=	TextFieldAutoSize.LEFT;
			_txt.type				=	TextFieldType.DYNAMIC;
			_txt.selectable			=	false;
			_txt.mouseWheelEnabled	=	false;
			
			_tf				=	new TextFormat();
			_tf.font		=	"微软雅黑";
			_tf.color		=	uint("0x"+txtColor);
			
			_txt.defaultTextFormat	=	_tf;
			
			if(size!=12)
			{
				_tf.color		=	txtColor;
				_tf.size		=	18;
			}
			if(StaticIni.getIniVar("textColor",txtColor)!=null)
			{
				_color	=	StaticIni.getIniVar("textColor",txtColor);
			}
			else
			{
				_color	=	txtColor;
			}
			
			//添加显示
			addChild(_txt);
		}
		
		/**
		 * 设置发光 
		 * @param val
		 * 
		 */
		public function set htmlByBorder(val:String):void
		{
			htmlStr	=	val;
			_txt.filters	=	[_labelFilter];
		}
		
		/**
		 * 取得文字内容 
		 * @return 
		 * 
		 */
		public function get htmlStr():String
		{
			return _htmlStr;
		}

		/**
		 * 设置文字内容 
		 * @param value
		 * 
		 */
		public function set htmlStr(value:String):void
		{
			_htmlStr = value;
			_txt.filters	=	null;
			_txt.htmlText	=	value;
		}

		public function get labelFilter():GlowFilter
		{
			return _labelFilter;
		}

		public function set labelFilter(value:GlowFilter):void
		{
			_labelFilter = value;
		}
		public function set tf(val:TextFormat):void
		{
			_tf = val;
		}
	}
}